package com.meituan.service.impl;

import com.meituan.dao.GoodsDao;
import com.meituan.pojo.entity.Goods;
import com.meituan.pojo.resp.BaseResp;
import com.meituan.service.GoodsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Optional;

@Service
public class GoodsServiceImpl implements GoodsService {

    @Autowired
    GoodsDao dao;


    @Override
    public BaseResp findBySid(Integer sid) {
        return new BaseResp(1,"success",dao.findBySid(sid));
    }

    @Override
    public BaseResp update(Goods goods) {
        return new BaseResp(1,"success",dao.saveAndFlush(goods));
    }

    @Override
    public BaseResp findByGid(Integer gid) {
        Optional<Goods> byId = dao.findById(gid);
        Goods goods = byId.get();
        return new BaseResp(1,"成功",goods);
    }

}
